# Contributor: Guy Godfroy <guy.godfroy@gugod.fr>
# Maintainer: Guy Godfroy <guy.godfroy@gugod.fr>
pkgname=prometheus-smartctl-exporter
_pkgname=smartctl_exporter
pkgver=0.12.0
pkgrel=2
pkgdesc="Prometheus smartctl exporter"
url="https://github.com/prometheus-community/smartctl_exporter"
arch="all"
license="LGPL-3.0-or-later"
depends="smartmontools jq"
makedepends="go"
install="$pkgname.pre-install"
subpackages="$pkgname-openrc"
source="$_pkgname-$pkgver.tar.gz::$url/archive/v$pkgver.tar.gz
	smartctl-exporter.initd
	smartctl-exporter.confd
	"
builddir="$srcdir/$_pkgname-$pkgver"
options="net"

build() {
	GOLDFLAGS="-X main.Version=$pkgver"
	go build \
		-tags netgo \
		-ldflags "$GOLDFLAGS" \
		-o smartctl-exporter
}

check() {
	go test -cover ./...
}

package() {
	install -Dm755 smartctl-exporter "$pkgdir"/usr/bin/smartctl-exporter
	install -Dm755 "$srcdir"/smartctl-exporter.initd "$pkgdir"/etc/init.d/smartctl-exporter
	install -Dm644 "$srcdir"/smartctl-exporter.confd "$pkgdir"/etc/conf.d/smartctl-exporter
}

sha512sums="
8f2cc973fd967c9ab737dcaa7456f019cb574ac3297bd5d15559167cde51f8076bcb48c7befb7efb869e056c1c5e404f4bb2774e8fe020736354ede4ae3e77f3  smartctl_exporter-0.12.0.tar.gz
605e753b3f90bf20c035798af9702f60d7f39d600e96a5d5b6cc8909334c2e6adb8fae6f6f3a7cfb4b097e2ceeb90257d9041d41aefa891e25aabf7cc2cac9e2  smartctl-exporter.initd
cd46f20e8b479331e4e831da1dd36fcd93990904560555b5ba67d2344dc50405d8d8e4a3b03c32b1aaf969fed0a2a176c5248e671495604112fafb6dc325b999  smartctl-exporter.confd
"
